﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminPanel/AdminSite.Master" AutoEventWireup="true"
CodeBehind="ConfirmBooking.aspx.cs" Inherits="FastTrackCabService.AdminPanel.ConfirmBooking" %>
<%@ Import Namespace="BusinessLogicLayer" %>
<%@ Import Namespace="BusinessObjects" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Style/FullView.css" rel="stylesheet" type="text/css"/>
    <link href="../Style/ConfirmBooking.css" rel="stylesheet" type="text/css"/>
    <link href="../Style/jquery-ui.css" rel="stylesheet" type="text/css"/>
    <link href="../Style/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css"/>
    <script src="../Scripts/jquery-1.11.3.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
    <script type="text/javascript">
        function deliveryChange() {
            var deliveryDateTime = document.getElementById("ContentPlaceHolder1_tbDelivery").value;
            document.getElementById("ContentPlaceHolder1_hdnDelivery").value = deliveryDateTime;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:DetailsView ID="dvPickAndDrop" Visible="False" CssClass="detailsView" runat="server"
                 AutoGenerateRows="False" CellPadding="4" ForeColor="#333333" GridLines="None"
                 HeaderText="Booking details">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
    <EditRowStyle BackColor="#999999"/>
    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
    <Fields>
        <asp:BoundField DataField="BookingId" HeaderText="Booking Id" SortExpression="BookingId"/>
        <asp:TemplateField HeaderText="Customer" SortExpression="CustomerId">
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# "<a href=\"CustomerFullView.aspx?cusId=" + Eval("CustomerId") + "\">" + CustomerBLL.GetCustomerName(Convert.ToInt32(Eval("CustomerId"))) + "</a>" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="BookedDateTime" HeaderText="Booked date &amp; time" SortExpression="BookedDateTime"/>
        <asp:BoundField DataField="OriginDateTime" HeaderText="Pickup date &amp; time" SortExpression="OriginDateTime"/>
        <asp:TemplateField HeaderText="From">
            <ItemTemplate>
                <asp:DetailsView ID="DetailsView2" Style="width: 100%;" CssClass="innerDetailsView"
                                 runat="server" CellPadding="4" DataSource='<%# new List<CurrentLocation> {(CurrentLocation) Eval("OriginLocation")} %>'
                                 ForeColor="#333333" GridLines="None" Height="50px" Width="125px" AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
                    <EditRowStyle BackColor="#999999"/>
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
                    <Fields>
                        <asp:BoundField DataField="HomeNumberOrName" HeaderText="No / Name"/>
                        <asp:BoundField DataField="Street" HeaderText="Street"/>
                        <asp:BoundField DataField="City" HeaderText="City"/>
                        <asp:TemplateField HeaderText="District">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# DistrictBLL.GetDistrict(Convert.ToByte(Eval("DistrictId"))) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                </asp:DetailsView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="MidPoint" HeaderText="To" SortExpression="MidPoint"/>
        <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type"/>
        <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status"/>
        <asp:TemplateField HeaderText="Vehicle(s)">
            <ItemTemplate>
                <asp:DetailsView ID="DetailsView3" Style="width: 100%;" CssClass="innerDetailsView"
                                 runat="server" CellPadding="4" DataSource='<%# new List<BookingVehicleRequirement> {(BookingVehicleRequirement) Eval("VehicleRequirement")} %>'
                                 ForeColor="#333333" GridLines="None" Height="50px" Width="125px" AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
                    <EditRowStyle BackColor="#999999"/>
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
                    <Fields>
                        <asp:BoundField DataField="NumberOfCars" HeaderText="Car(s)"/>
                        <asp:BoundField DataField="NumberOfVans" HeaderText="Van(s)"/>
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                </asp:DetailsView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <ItemStyle BackColor="#E2DED6"/>
            <ItemTemplate>
                <div style="text-align: center;">
                    <asp:ImageButton ID="ibReject" Style="display: table-cell; margin: auto; outline: none;"
                                     OnClick="ibReject_OnClick" OnClientClick=" if (!confirm('Are you sure do you want to reject this booking?')) return false; "
                                     ToolTip="Reject this booking" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/reject_x.png" runat="server"/>
                </div>
            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
</asp:DetailsView>
<asp:DetailsView ID="dvPick" Visible="False" CssClass="detailsView" runat="server"
                 AutoGenerateRows="False" CellPadding="4" ForeColor="#333333" GridLines="None"
                 HeaderText="Booking details">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
    <EditRowStyle BackColor="#999999"/>
    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
    <Fields>
        <asp:BoundField DataField="BookingId" HeaderText="Booking Id" SortExpression="BookingId"/>
        <asp:TemplateField HeaderText="Customer" SortExpression="CustomerId">
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# "<a href=\"CustomerFullView.aspx?cusId=" + Eval("CustomerId") + "\">" + CustomerBLL.GetCustomerName(Convert.ToInt32(Eval("CustomerId"))) + "</a>" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="BookedDateTime" HeaderText="Booked date &amp; time" SortExpression="BookedDateTime"/>
        <asp:BoundField DataField="OriginDateTime" HeaderText="Pickup date &amp; time" SortExpression="OriginDateTime"/>
        <asp:TemplateField HeaderText="From">
            <ItemTemplate>
                <asp:DetailsView ID="DetailsView2" Style="width: 100%;" CssClass="innerDetailsView"
                                 runat="server" CellPadding="4" DataSource='<%# new List<CurrentLocation> {(CurrentLocation) Eval("OriginLocation")} %>'
                                 ForeColor="#333333" GridLines="None" Height="50px" Width="125px" AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
                    <EditRowStyle BackColor="#999999"/>
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
                    <Fields>
                        <asp:BoundField DataField="HomeNumberOrName" HeaderText="No / Name"/>
                        <asp:BoundField DataField="Street" HeaderText="Street"/>
                        <asp:BoundField DataField="City" HeaderText="City"/>
                        <asp:TemplateField HeaderText="District">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# DistrictBLL.GetDistrict(Convert.ToByte(Eval("DistrictId"))) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                </asp:DetailsView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Destination" HeaderText="To" SortExpression="Destination"/>
        <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type"/>
        <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status"/>
        <asp:TemplateField HeaderText="Vehicle(s)">
            <ItemTemplate>
                <asp:DetailsView ID="DetailsView3" Style="width: 100%;" CssClass="innerDetailsView"
                                 runat="server" CellPadding="4" DataSource='<%# new List<BookingVehicleRequirement> {(BookingVehicleRequirement) Eval("VehicleRequirement")} %>'
                                 ForeColor="#333333" GridLines="None" Height="50px" Width="125px" AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
                    <EditRowStyle BackColor="#999999"/>
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
                    <Fields>
                        <asp:BoundField DataField="NumberOfCars" HeaderText="Car(s)"/>
                        <asp:BoundField DataField="NumberOfVans" HeaderText="Van(s)"/>
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                </asp:DetailsView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <ItemStyle BackColor="#E2DED6"/>
            <ItemTemplate>
                <div style="text-align: center;">
                    <asp:ImageButton ID="ibReject" Style="outline: none;" OnClick="ibReject_OnClick"
                                     OnClientClick=" if (!confirm('Are you sure do you want to reject this booking?')) return false; "
                                     ToolTip="Reject this booking" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/reject_x.png" runat="server"/>
                </div>
            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
</asp:DetailsView>
<table class="table">
    <tr>
        <th colspan="2">
            Allocations
        </th>
    </tr>
    <tr>
        <td>
            Subsidiary under pickup district
        </td>
        <td>
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="ddlSubsidiaries" AutoPostBack="True" OnSelectedIndexChanged="ddlSubsidiaries_OnSelectedIndexChanged"
                                      runat="server">
                    </asp:DropDownList>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td>
            Supervisor
        </td>
        <td>
            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="ddlSupervisor" runat="server">
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rfvSupervisor" runat="server" ErrorMessage="Supervisor is required!"
                                                ForeColor="Red" Text="*" Display="Dynamic" ControlToValidate="ddlSupervisor"
                                                ValidationGroup="book">
                    </asp:RequiredFieldValidator>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td>
            Vehicle(s)
            <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                <ContentTemplate>
                    <table id="tblAddVehicle" style="margin-top: 0.5em;" runat="server">
                        <tr>
                            <th>
                                Type
                            </th>
                            <th>
                                Vehicle
                            </th>
                            <th>
                                Driver
                            </th>
                            <th>
                                Action
                            </th>
                        </tr>
                        <tr id="trCar" runat="server">
                            <td>
                                Car
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlCar" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlCarDriver" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td style="text-align: center;">
                                <asp:ImageButton ID="ibCar" OnClick="ibCar_OnClick" ImageUrl="~/Images/add_blue.png"
                                                 Style="outline: none;" ToolTip="Add" runat="server"/>
                            </td>
                        </tr>
                        <tr id="trVan" runat="server">
                            <td>
                                Van
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlVan" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlVanDriver" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td style="text-align: center;">
                                <asp:ImageButton ID="ibVan" OnClick="ibVan_OnClick" ImageUrl="~/Images/add_blue.png"
                                                 Style="outline: none;" ToolTip="Add" runat="server"/>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
        <td>
            <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                        <EditRowStyle BackColor="#999999"/>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
                        <SortedAscendingCellStyle BackColor="#E9E7E2"/>
                        <SortedAscendingHeaderStyle BackColor="#506C8C"/>
                        <SortedDescendingCellStyle BackColor="#FFFDF8"/>
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
                    </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td>
            Approximate end date & time
        </td>
        <td>
            <asp:TextBox ID="tbDelivery" MaxLength="0" onchange="deliveryChange();" placeholder="mm/dd/yyyy hh:MM a"
                         ReadOnly="True" runat="server">
            </asp:TextBox>
            <asp:HiddenField runat="server" ID="hdnDelivery"/>
            <asp:RequiredFieldValidator ID="rfvApproxDate" ValidationGroup="book" ForeColor="Red" Text="*" Display="Dynamic" ControlToValidate="tbDelivery" runat="server" ErrorMessage="Approximate end date & time is required!"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td colspan="2" style="background: #E2DED6; text-align: center;">
            <asp:ImageButton ID="ibReset" OnClick="ibReset_OnClick" Style="outline: none;" ToolTip="Reset"
                             ImageUrl="~/Images/reload.png" runat="server"/>
            <asp:ImageButton ID="ibApproved" Style="margin-left: 1em; outline: none;" OnClick="ibApproved_OnClick"
                             ToolTip="Approve and save this booking" ImageUrl="~/Images/approved.png" runat="server"
                             ValidationGroup="book"/>
        </td>
    </tr>
    <tr>
        <td colspan="2" style="background: #E2DED6;">
            <asp:ValidationSummary ID="ValidationSummary1" ForeColor="Red" HeaderText="<b>Please fix following error(s)</b>"
                                   CssClass="validationSummary" runat="server" ValidationGroup="book"/>
            <asp:Label ID="lblError" runat="server" Text="Requested amount of vehicle(s) doesn't match!"
                       ForeColor="Red" Visible="False">
            </asp:Label>
        </td>
    </tr>
</table>
<script type="text/javascript">

    $("#ContentPlaceHolder1_tbDelivery").datetimepicker({
        timeFormat: "hh:mm tt"
    });

</script>
</asp:Content>